﻿using System.Collections.Generic;
//
using PerceptiveMCAPI;
//

namespace PerceptiveMCAPI_Test
{
   public partial class get_campaignShareReport : System.Web.UI.UserControl
   {
      public ApiMethod method { get; set; }

      public string campaignId
      {
         get { return tbCampaignId.Text.Trim(); }
         set { tbCampaignId.Text = value; }
      }
      public Dictionary<string, object> opts
      {
         get { return getOptions(); }
      }

      public void Setup()
      {
         this.Visible = true;
         lblSection.Text = method.section;
         lblMethod.Text = method.name;
         //
         tbCampaignId.Focus();
         rbHeader_type.SelectedValue = MCAPISettings.default_campaignShareReport_header_type;
         tbHeader_data.Text = MCAPISettings.default_campaignShareReport_header_data;
         cbSecure.Checked = (bool)MCAPISettings.default_campaignShareReport_secure;
         tbCss_Url.Text = MCAPISettings.default_campaignShareReport_css_url;
         //
      }
      // ---------------------------------------
      private Dictionary<string, object> getOptions()
      {
         Dictionary<string, object> opts = new Dictionary<string, object>();
         opts.Add( "header_type", rbHeader_type.SelectedValue );
         if ( !string.IsNullOrEmpty( tbHeader_data.Text ) )
            opts.Add( "header_data", tbHeader_data.Text.Trim() );
         opts.Add( "secure", cbSecure.Checked );
         if ( !string.IsNullOrEmpty( tbPassword.Text ) )
            opts.Add( "password", tbPassword.Text.Trim() );
         if ( !string.IsNullOrEmpty( tbTo_Email.Text ) )
            opts.Add( "to_email", tbTo_Email.Text.Trim() );
         if ( !string.IsNullOrEmpty( tbCss_Url.Text ) )
            opts.Add( "css_url", tbCss_Url.Text.Trim() );
         // -- theme colors
         Dictionary<string, string> theme = new Dictionary<string, string>();
         if ( !string.IsNullOrEmpty( tbBg_Color.Text ) )
            theme.Add( "bg_color", tbBg_Color.Text.Trim() );
         if ( !string.IsNullOrEmpty( tbHeader_Color.Text ) )
            theme.Add( "header_color", tbHeader_Color.Text.Trim() );
         if ( !string.IsNullOrEmpty( tbCurrent_Tab.Text ) )
            theme.Add( "current_tab", tbCurrent_Tab.Text.Trim() );
         if ( !string.IsNullOrEmpty( tbCurrent_Tab_Text.Text ) )
            theme.Add( "current_tab_text", tbCurrent_Tab_Text.Text.Trim() );
         if ( !string.IsNullOrEmpty( tbNormal_Tab.Text ) )
            theme.Add( "normal_tab", tbNormal_Tab.Text.Trim() );
         if ( !string.IsNullOrEmpty( tbNormal_Tab_Text.Text ) )
            theme.Add( "normal_tab_text", tbNormal_Tab_Text.Text.Trim() );
         if ( !string.IsNullOrEmpty( tbHover_Tab.Text ) )
            theme.Add( "hover_tab", tbHover_Tab.Text.Trim() );
         if ( !string.IsNullOrEmpty( tbHover_Tab_Text.Text ) )
            theme.Add( "hover_tab_text", tbHover_Tab_Text.Text.Trim() );
         //
         if ( theme.Count > 0 )
            opts.Add( "theme", theme );
         // ------------------------------
         return opts;
      }
      // --------------------------------------------
   }
}